package org.HisCanvas.ChrisRiffle.JFlightLog.swingUi.recordDetailWindow;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;

public class LogBookRecOkCancelButtonPanel extends JPanel{

	
	private static final String OK_BUTTON_TEXT = "Ok";
	
	private static final String CANCEL_BUTTON_TEXT = "Cancel";
	
	
	private JButton okButton;
	
	private JButton cancelButton;

	
	public LogBookRecOkCancelButtonPanel() {
		
		init();
	}
	

	private void init() {
	
	

		GroupLayout groupLayout = new GroupLayout(this);

		groupLayout.setAutoCreateGaps(true);

		this.setLayout(groupLayout);

		groupLayout.setHorizontalGroup(groupLayout.createSequentialGroup()
				.addComponent(getOkButton())
				.addComponent(getCancelButton()));

		groupLayout.setVerticalGroup(groupLayout.createParallelGroup()
				.addComponent(getOkButton())
				.addComponent(getCancelButton()));

		groupLayout.linkSize(getOkButton(), getCancelButton());		
	}
	
	

	/**
	 * Gets the okButton
	 * 
	 * @return the okButton
	 */
	public JButton getOkButton() {
		
		if (okButton == null) {
			
			okButton = new JButton(OK_BUTTON_TEXT);
		}
		return okButton;
	}

	
	/**
	 * Gets the cancelButton
	 * 
	 * @return the cancelButton
	 */
	public JButton getCancelButton() {
		
		if (cancelButton == null) {
			
			cancelButton = new JButton(CANCEL_BUTTON_TEXT);
		}
		return cancelButton;
	}

	
	/**
	 * test driver
	 */
	public static void main(String[] args) {
		

		JDialog d = new JDialog();
		LogBookRecOkCancelButtonPanel p = new LogBookRecOkCancelButtonPanel();
		d.setContentPane(p);
		d.pack();
		d.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {			
				System.exit(0);
			}
		});
		d.setLocationRelativeTo(null);
		d.setVisible(true);
	
	}
	
	
}



